type ImageType = HTMLImageElement;
export declare function getDataUrl(image: ImageType | HTMLCanvasElement): string;
export declare function cloneToCanvas(image: ImageType): HTMLCanvasElement;
export declare function cloneImage(image: ImageType | HTMLCanvasElement): ImageType;
export declare function responseToImageUrl(response: Response): Promise;
export declare function imageToResponse(image: any): Response;
type spriteCfg = {
x: number;
y: number;
width: number;
height: number;
};
interface SpritesheetConfig {
fileName: string;
sprites: {
[name: string]: spriteCfg;
};
}
export declare class Spritesheet {
id: string;
loaded: boolean;
sprite: HTMLImageElement;
config: SpritesheetConfig;
constructor(options: {
id: string;
url: string;
cache?: true;
config: SpritesheetConfig;
});
}
declare class SpriteOld {
img: ImageType;
constructor(image: ImageType);
}
export default class Sprites {
static slice(image: ImageType, bounds: {
x: number;
y: number;
width: number;
height: number;
}): ImageType;
static Slice: typeof Sprites.slice;
canvas: import("./index.js").ChainableCanvas;
/**
* Host domain and or path
* it's essentially just a url prefix
*/
host: string;
sprites: Map;
loading: Set;
readonly cache: Map;
/** Seconds */
cache_duration: number;
readonly sheets: Map;
constructor(options?: {
host?: string;
cacheDuration?: number;
});
addSpritesheet(spritesheet: Spritesheet): void;
parseUrl(url: string): string;
has(url: string): boolean;
get(url: string, options?: any): HTMLImageElement;
loadSingle(url: string, onLoad?: Function): SpriteOld;
fromCache(url: string): Promise;
loadSinglePromise(url: string): Promise;
promise(url: string): Promise;
}
export declare class OraSpritesheet {
id: string;
sprites: Record;
canvas: HTMLCanvasElement;
ctx: CanvasRenderingContext2D;
constructor(id: string);
set(list: [id: string, image: HTMLImageElement][]): void;
getAll(): [id: string, image: HTMLImageElement][];
inject(id: string, image: HTMLImageElement): void;
}
export declare class Textures {
static tempPromised(promise: Promise): HTMLImageElement;
cache: {
sheets: Set;
};
inject(image: HTMLImageElement): void;
get(url: string): void;
}
export {};